﻿/*********************************************
 * Author: resaberonjr
 * DateWritten: 09/2011
 *********************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RootBaseFramework.Infra.Data
{
    public class UnitOfWork : IUnitOfWork
    {

        public UnitOfWork(IContext context)
        {
            Context = context;
        }

        public IContext Context { get; private set; }
        
        public void Commit()
        {
            Context.SaveChanges();
        }

        private bool _disposed = false;

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if (Context != null) 
                        Context.Dispose();
                }
            }
            _disposed = true;
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }

   


   
}
